package com.itwxz.forum.controller.mobile;


import cn.dev33.satoken.annotation.SaIgnore;
import com.itwxz.common.annotation.Log;
import com.itwxz.common.config.QiNiuConfig;
import com.itwxz.common.core.controller.BaseController;
import com.itwxz.common.core.domain.AjaxResult;
import com.itwxz.common.core.domain.R;
import com.itwxz.common.core.page.TableDataInfo;
import com.itwxz.common.enums.BusinessType;
import com.itwxz.common.utils.bean.BeanUtils;
import com.itwxz.common.utils.poi.ExcelUtil;
import com.itwxz.forum.domain.po.ForumConfig;
import com.itwxz.forum.domain.vo.ForumConfigVo;
import com.itwxz.forum.service.ForumConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 手机端论坛参数配置Controller
 *
 * @author gastronome
 * @date 2025-05-18
 */
@Tag(name = "手机端论坛参数配置Controller")
@RestController
@RequestMapping("/forum/mobile/config")
public class ForumConfigMobileController extends BaseController {
	@Autowired
	private ForumConfigService configService;

	@GetMapping
	@SaIgnore
	@Cacheable(value = "config", key = "'forum'")
	public R<Map<String, String>> getRepairConfig() {
		Map<String, String> result = configService.lambdaQuery()
				.list()
				.stream()
				.map(config -> BeanUtils.copyBean(config, ForumConfigVo.class))
				.collect(Collectors.toMap(ForumConfigVo::getConfigKey, ForumConfigVo::getConfigValue));

		return R.ok(result);
	}
}
